<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>魏远商城</title>
		<meta name="viewport" content="initial-scale=1, maximum-scale=1">
		<link rel="shortcut icon" href="/favicon.ico">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="css/my-order.css" />
		<link rel="stylesheet" href="css/style.css" />
		<link rel="stylesheet" type="text/css" href="css/return.css" />
		<style>
			.return-content>div:nth-child(1) {
				display: block;
			}
			
			.return-content>div:nth-child(2) {
				display: none;
			}
			
			.return-content>div:nth-child(3) {
				display: none;
			}
			
			.return-content>div:nth-child(4) {
				display: none;
			}
			
			.return-content>div {
				width: 100%;
			}
		</style>
	</head>

	<body style="background: #eaeef1;">
		<header class="bar bar-nav return-header" style="width: 100%;">
			<span class="mui-action-back order-back"><img src="img/back-le.png" height="50%"/></span>
			<h1 class="title" style="line-height: 2.2rem;">退换货</h1>
		</header>

		<div class="ruturn-title">
			<span class="return-add">退货进行中</span>
			<span>退货已完成</span>
			<span>退款进行中</span>
			<span>退款已完成</span>
		</div>

		<div class="return-content">
			<div class="tui1">

				<!--<img src="img/none.png" alt="" width="40%" style="margin-top: 80px;" />-->
			</div>
			<div class="tui2">
				<!--<img src="img/none.png" alt="" width="40%" style="margin-top: 80px;" />-->
			</div>
			<div class="kuan1">
				<!--<img src="img/none.png" alt="" width="40%" style="margin-top: 80px;" />-->
			</div>
			<div class="kuan2">
				<!--<img src="img/none.png" alt="" width="40%" style="margin-top: 80px;" />-->
			</div>
			<!--<img src="img/none.png" alt="" width="40%" style="margin-top: 80px;" />-->
		</div>

		<script src="js/jquery-3.1.1.min.js"></script>
		<script src="js/mui.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/url.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			//			mui.plusReady(function() {
			//				plus.nativeUI.showWaiting()
			var text1 = $('<div style="padding-top: 50px;font-size: 16px;">拼命加载中...</div>');
			$('.tui1').append(text1);
			$('.tui2').append(text1);
			$('.kuan1').append(text1);
			$('.kuan2').append(text1);
			localStorage.noStatesStr = '5';
			localStorage.refundType = '13';
			localStorage.price = '';
			tuihuo();
			//			localStorage.token = 'BBDC4141D7A3426FB31C174A43F01F3A';
			$('.ruturn-title>span').on("touchstart", function() {
				var index = $(this).index();
				$(this).siblings().removeClass('return-add');
				$(this).addClass("return-add");
				$('.return-content>div').eq(index).css('display', 'block');
				$('.return-content>div').eq(index).siblings().css('display', 'none');
				if(index == 0) {
					localStorage.noStatesStr = '5';
					localStorage.refundType = '13';
					localStorage.price = '';
					$('.tui1').html('');
					tuihuo();
				} else if(index == 1) {
					localStorage.noStatesStr = '15,19';
					localStorage.refundType = '13';
					localStorage.price = '';
					$('.tui2').html('');
					tuihuo();
				} else if(index == 2) {
					$('.kuan1').html('');
					localStorage.refunded = '8';
					localStorage.price = '';
					tuikuan()
				} else {
					$('.kuan2').html('');
					localStorage.refunded = '7';
					localStorage.price = '';
					tuikuan()
				}
			})
			//			成功
			//						"noStatesStr": '15,19',
			////						"state": 5,
			//						"refundType": 13,

			function tuihuo() {
				$.ajax({
					url: ur + '/mobilemember/frontmember/findRefundGoodsList',
					type: 'POST',
					headers: {
						"X-Token": localStorage.token
					},
					dataType: 'json',
					//					退货进行中
					data: {
						"noStatesStr": localStorage.noStatesStr,
						//						"state": 5,
						"refundType": localStorage.refundType,
					},
					success: function(data) {

						//							plus.nativeUI.closeWaiting()
						console.log(JSON.stringify(data) + ">>>>>");
						console.log(data.result.meta.code + '成功状态码');
						var img = $('<img src="img/none.png" alt="" width="40%" style="margin-top: 80px;" />');
						//						非空

						//							填充
						if(localStorage.noStatesStr == '5') {
							if(data.result.meta.code == '202') {
								$('.tui1').append(img);
							}
							if(data.result.meta.code == '200') {
								for(var i = 0; i < data.result.data.refundgoodsVOList.length; i++) {
									var opinion = data.result.data.refundgoodsVOList[i].remark == null ? '' : data.result.data.refundgoodsVOList[i].remark;
									var pri = 0;
									var n = data.result.data.refundgoodsVOList[i].refundGoodsproductVOs.length;
									for(var j = 0; j < n; j++) {
										pri = pri + data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].price;
										localStorage.price = pri;
									}
									var div = $('<div class="main">' +
										'<p><span>店铺名称：魏远商城</span><span class="zt"></span></p>' +

										'<p>订单编号: ' + data.result.data.refundgoodsVOList[i].orderNum + '<span style="float: right;">'+opinion+'</span></p>' +

										'<div class="' + i + ' main_m">' +
										//某个
										'</div>' +
										'<p class="a3"><span>共' + n + '件商品 合计：<span>￥' +localStorage.price + '</span></span></p>' +
										'<p class="a4"><span>' + data.result.data.refundgoodsVOList[i].createTime + '</span><span>退款总金额￥' + localStorage.price + '</span></p>' +
										'</div>'
									);
									$('.zt').html('正在退货中');
									$('.tui1').append(div);
//									var pic = 'http://192.168.0.209:8888';
									for(var j = 0; j < n; j++) {
										var b = data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].mainIng;
//										console.log(b.indexOf(',') + '逗号索引值');
										var m = b.indexOf(',');
										if(m != '-1') {
											var mainImg = b.substring(0, m);
										} else {
											mainImg = b;
										}
										//									console.log(data.result.data.refundgoodsVOList[0].refundGoodsproductVOs[j].price + '价格');
										//									console.log(data.result.data.refundgoodsVOList[0].refundGoodsproductVOs[0].price)
										var div2 = $('<span style="background-image: url(' + pic + mainImg + ');"></span>' +
											'<span>' + data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].shortname + '</span>' +
											'<span>' +
											'<span>￥' + data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].price + '</span>' +
											'<span></span>' +
											'<span>X' + data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].amount + '</span>' +
											'</span>'
										);
										$('.' + i).append(div2);
									}
								}

							}
						} else {
							if(data.result.meta.code == '202') {
								$('.tui2').append(img);
							}
							if(data.result.meta.code == '200') {
								for(var i = 0; i < data.result.data.refundgoodsVOList.length; i++) {
									var opinion = data.result.data.refundgoodsVOList[i].remark == null ? '' : data.result.data.refundgoodsVOList[i].remark;
									var pri = 0;
									var n = data.result.data.refundgoodsVOList[i].refundGoodsproductVOs.length;
									for(var j = 0; j < n; j++) {
										pri = pri + data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].price;
										localStorage.price = pri;
									}
									var div = $('<div class="main">' +
										'<p><span>店铺名称：魏远商城</span><span class="zt"></span></p>' +

										'<p>订单编号: ' + data.result.data.refundgoodsVOList[i].orderNum + '<span style="float: right;">'+opinion+'</span></p>' +

										'<div class="' + i + ' main_m">' +
										//某个
										'</div>' +
										'<p class="a3"><span>共' + n + '件商品 合计：<span>￥' + localStorage.price + '</span></span></p>' +
										'<p class="a4"><span>' + data.result.data.refundgoodsVOList[i].createTime + '</span><span>退款总金额￥' + localStorage.price + '</span></p>' +
										'</div>'
									);
									$('.zt').html('退货已完成');
									$('.tui2').append(div);
									var pic = 'http://192.168.0.209:8888';
									for(var j = 0; j < n; j++) {
										var b = data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].mainIng;
										console.log(b.indexOf(',') + '逗号索引值');
										var m = b.indexOf(',');
										if(m != '-1') {
											var mainImg = b.substring(0, m);
										} else {
											mainImg = b;
										}
										//									console.log(data.result.data.refundgoodsVOList[0].refundGoodsproductVOs[j].price + '价格');
										//									console.log(data.result.data.refundgoodsVOList[0].refundGoodsproductVOs[0].price)
										var div2 = $('<span style="background-image: url(' + pic + mainImg + ');"></span>' +
											'<span>' + data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].shortname + '</span>' +
											'<span>' +
											'<span>￥' + data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].price + '</span>' +
											'<span></span>' +
											'<span>X' + data.result.data.refundgoodsVOList[i].refundGoodsproductVOs[j].amount + '</span>' +
											'</span>'
										);
										$('.' + i).append(div2);
									}
								}

							}
						}

					},
					error: function(e) {
						console.log(JSON.stringify(e) + '错误')
					}
				})
			}

			function tuikuan() {
				$.ajax({
					url: ur + '/mobilemember/frontmember/findOrderRefundList',
					type: 'POST',
					headers: {
						"X-Token": localStorage.token
					},
					dataType: 'json',
					//					退货进行中
					data: {
						'refunded': localStorage.refunded
					},
					success: function(data) {
						//							plus.nativeUI.closeWaiting();
						console.log(JSON.stringify(data) + ">>>>>")
						console.log(data.result.meta.code + '成功状态码');
						var img = $('<img src="img/none.png" alt="" width="40%" style="margin-top: 80px;" />');
						if(localStorage.refunded == '7') {
							if(data.result.meta.code == '200') {
								for(var i = 0; i < data.result.data.orderRefundVOList.length; i++) {
									var opinion = data.result.data.orderRefundVOList[i].opinion == null ? '' : data.result.data.orderRefundVOList[i].opinion;
									var div = $('<div class="main">' +
										'<p><span>店铺名称：魏远商城</span><span class="zt">' + data.result.data.orderRefundVOList[i].statusName + '</span></p>' +
//<<<<<<< .mine
										'<p>订单编号: ' + data.result.data.orderRefundVOList[i].orderVO.orderNum + '<span style="float: right;">'+opinion+'</span></p>' +
										'<p class="b1"><span>退款原由: </span><span>' + data.result.data.orderRefundVOList[i].content + '</span></p>' +
										'<p class="b2"> <span>退款金额:</span><span>￥  ' + data.result.data.orderRefundVOList[i].amount + '</span></p>' +
//||||||| .r1244
//										'<p>订单编号: ' + data.result.data.orderRefundVOList[i].orderVO.orderNum + '</p>' +
//										'<p class="b1"><span>退款原由: </span><span>' + data.result.data.orderRefundVOList[i].content + '</span></p>' +
//										'<p class="b2"> <span>退款金额:</span><span>￥  ' + data.result.data.orderRefundVOList[i].amount + '</span></p>' +
//=======
//										'<p>订单编号：' + data.result.data.orderRefundVOList[i].orderVO.orderNum + '</p>' +
//										'<p class="b1"><span>退款原由：</span><span>' + data.result.data.orderRefundVOList[i].content + '</span></p>' +
//										'<p class="b2"> <span>退款金额：</span><span>￥' + data.result.data.orderRefundVOList[i].amount + '</span></p>' +
//>>>>>>> .r1361
										'<p class="b3"><span>' + data.result.data.orderRefundVOList[i].applyTime + '</span></p>' +
										'</div>'
									);
									$('.kuan2').append(div);
								}
								
							}
							if(data.result.meta.code == '202') {
								$('.kuan2').append(img);
							}
						} else {
							if(data.result.meta.code == '200') {
								for(var i = 0; i < data.result.data.orderRefundVOList.length; i++) {
									var opinion = data.result.data.orderRefundVOList[i].opinion == null ? '' : data.result.data.orderRefundVOList[i].opinion;
									var div = $('<div class="main">' +
										'<p><span>店铺名称：魏远商城</span><span class="zt">' + data.result.data.orderRefundVOList[i].statusName + '</span></p>' +
//<<<<<<< .mine
										'<p>订单编号: ' + data.result.data.orderRefundVOList[i].orderVO.orderNum + '<span style="float: right;">'+opinion+'</span></p>' +
										'<p class="b1"><span>退款原由: </span><span>' + data.result.data.orderRefundVOList[i].content + '</span></p>' +
										'<p class="b2"> <span>退款金额:</span><span>￥  ' + data.result.data.orderRefundVOList[i].amount + '</span></p>' +
//||||||| .r1244
//										'<p>订单编号: ' + data.result.data.orderRefundVOList[i].orderVO.orderNum + '</p>' +
//										'<p class="b1"><span>退款原由: </span><span>' + data.result.data.orderRefundVOList[i].content + '</span></p>' +
//										'<p class="b2"> <span>退款金额:</span><span>￥  ' + data.result.data.orderRefundVOList[i].amount + '</span></p>' +
//=======
//										'<p>订单编号：' + data.result.data.orderRefundVOList[i].orderVO.orderNum + '</p>' +
//										'<p class="b1"><span>退款原由：</span><span>' + data.result.data.orderRefundVOList[i].content + '</span></p>' +
//										'<p class="b2"> <span>退款金额：</span><span>￥' + data.result.data.orderRefundVOList[i].amount + '</span></p>' +
//>>>>>>> .r1361
										'<p class="b3"><span>' + data.result.data.orderRefundVOList[i].applyTime + '</span></p>' +
										'</div>'
									);
									$('.kuan1').append(div);
								}
								
							}
							if(data.result.meta.code == '202') {
								$('.kuan1').append(img);
							}
						}

					},
					error: function(e) {
						console.log(JSON.stringify(e) + '错误')
					}
				})
			}
			//			})
		</script>
	</body>

</html>